<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Lista dokumentów</title>
		
		<link rel="stylesheet" type="text/css" href="/static/css/jquery-ui-1.9.2.custom.min.css" />
		<link rel="stylesheet" type="text/css" href="/static/css/documents-list.css" />
		<link rel="stylesheet" type="text/css" href="/static/css/messages.css" />
		<script type="text/javascript" src="/static/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="/static/js/jquery-ui-1.9.2.custom.min.js"></script>
		<script>
		$(document).ready(function() {
			$('.message-flash').show('blind', 1000).hide('drop', { direction: 'down'}, 4000 );
		});
		</script> 
	</head>
	<body>
		<%@ include file="header.jsp" %>
		<div id="box">
			<div id="title" class="ui-widget">Lista dokumentów</div>
			<div id="panel" class="ui-corner-all">
				<div id="search" class="ui-widget">
					<form action="documents">
						<input name="q" type="text">
						<input name="mode" type="radio" value="native" checked>Natywne
						<input name="mode" type="radio" value="lucene">Lucene
						<input type="submit" value="szukaj">
					</form>
					<form action="documents">
						<input type="submit" value="resetuj">
					</form>
				</div>
				<div id="list">
				<table>
					<c:forEach var="item" items="${list}">
						<tr>
							<td>${item.id}</td>
							<td>${item.filename}</td>
							<td>
								<c:choose>
									<c:when test="${item.format == 'DOC'}"><img alt="${item.format}" src="/static/img/doc.png"></c:when>
									<c:when test="${item.format == 'DOCX'}"><img alt="${item.format}" src="/static/img/docx.png"></c:when>
									<c:when test="${item.format == 'ODT'}"><img alt="${item.format}" src="/static/img/odt.png"></c:when>
									<c:when test="${item.format == 'PDF'}"><img alt="${item.format}" src="/static/img/pdf.png"></c:when>
									<c:when test="${item.format == 'RTF'}"><img alt="${item.format}" src="/static/img/rtf.png"></c:when>
									<c:when test="${item.format == 'TXT'}"><img alt="${item.format}" src="/static/img/txt.png"></c:when>
									<c:otherwise>${item.format}</c:otherwise>
								</c:choose>
							</td>
							<td>${item.type}</td>
							<td><a href="<c:url value="/document-display?id=${item.id}"></c:url>">pokaż</a></td>
							<td><a href="<c:url value="/delete-document?id=${item.id}"></c:url>">usuń</a></td>
						</tr>
					</c:forEach>
				</table>
				</div>
			</div>
			<%@ include file="messages.jsp" %>
		</div>
	</body>
</html>